package com.zyy.java8.samples.lambda;

/**
 * @author zhangyiying
 * @ClassName: Lambda4
 * @Description:
 * @date 2021/12/27 10:39
 */
public class Lambda4 {

    static int outStaticNum;

    int outerNum;

    void testScopes() {
        int num = 1;

        Lambda2.Converter<Integer, String> stringConverter = from -> String.valueOf(from + num);

        String convert = stringConverter.convert(2);
        // 3
        System.out.println(convert);


        Lambda2.Converter<Integer, String> stringConverter2 = from -> {
            outStaticNum = 13;
            return String.valueOf(from);
        };
        stringConverter2.convert(3);
        // 13
        System.out.println(outStaticNum);
        ;

        String[] array = new String[1];
        Lambda2.Converter<Integer, String> stringConverter3 = from -> {
            array[0] = "Hi there";
            return String.valueOf(from);
        };

        stringConverter3.convert(23);
        // Hi there
        System.out.println(array[0]);

    }

    public static void main(String[] args) {
        new Lambda4().testScopes();
    }
}
